﻿;/*
; *	Copyright (C) 2025 TTLzi
; *
; *	All Rights Reserved.
; *
; *	@file		Poe_AutoAlteration&Essence.ahk
; *
; *	@par		Poe_AutoAlteration&Essence.ini
; *
; *	@author		TTLzi
; *
; *	@brief		POE1自动改造&精华
; *
; *	@data		2025-08-20
; *
; *	@version	Beta 0.1
; *
; *	@note		无
; */	
;/**********************************软件配置***********************************t*/
;设置脚本当前所在位置为工作区
SetWorkingDir %A_ScriptDir%

;设置配置文件名为Poe_AutoAlteration&Essence.ini
ConfigFile := "Poe_AutoAlteration&Essence.ini"
;/**********************************全局变量***********************************t*/
global ProgramStatus 		:= false
global ProgramStatusText 	:= 停止
global ProgramHandleMutex	:= 0
;/**********************************地址配置*************************************/
global AlterationXPos		:= 1
global AlterationYPos		:= 1
global EssenceXPos			:= 2
global EssenceYPos			:= 2
global ItemXPos1			:= 10
global ItemYPos1			:= 10
global ItemXPos2			:= 20
global ItemYPos2			:= 20
global ItemXPos3			:= 30
global ItemYPos3			:= 30
global ItemXPos4			:= 40
global ItemYPos4			:= 40
global ItemXPos5			:= 50
global ItemYPos5			:= 50
global ItemXPos6			:= 60
global ItemYPos6			:= 60
;/**********************************基础配置*************************************/
global InputStatus 			:= 改造
global ItemStatus1			:= 0
global ItemStatus2			:= 0
global ItemStatus3			:= 0
global ItemStatus4			:= 0
global ItemStatus5			:= 0
global ItemStatus6			:= 0
;/**********************************词缀配置*************************************/
global ModifiersStatus1		:= 0
global ModifiersStatus2		:= 0
global ModifiersStatus3		:= 0
global ModifiersStatus4		:= 0
global ModifiersStatus5		:= 0
global ModifiersStatus6		:= 0
global ModifiersStatus7		:= 0
global ModifiersStatus8		:= 0
global ModifiersStatus9		:= 0
global ModifiersStatus10	:= 0
global ModifiersStr1		:= "一"
global ModifiersStr2		:= "二"
global ModifiersStr3		:= "三"
global ModifiersStr4		:= "四"
global ModifiersStr5		:= "五"
global ModifiersStr6		:= "六"
global ModifiersStr7		:= "七"
global ModifiersStr8		:= "八"
global ModifiersStr9		:= "九"
global ModifiersStr10		:= "十"
;/**********************************统计配置*************************************/
;/**********************************其他配置*************************************/
global InputXPos 			:= 0
global InputYPos 			:= 0
global SaveInfoStatus 		:= 0
global ShowInfoStatus		:= 0
global GetMouseAddrStatus 	:= 0
global AlterationMaxNum		:= 0
global EssenceMaxNum		:= 0

global ItemXPos_Temp		:= 0
global ItemYPos_Temp		:= 0
global ItemIndex_Temp		:= 1
global ItemIndex_Old		:= 0
;/**********************************代码区域*************************************/
Gui, Font, s14

Gui, Add, Text, vProgramStatusText cRed h25 x10 y10, 停止

Gui, Add, Button, vSaveConfigStatus gSaveConfigCallback w100 h30 x140 y10, 保存配置

Gui, Add, Button, vUserManualStatus gUserManualCallback w100 h30 x245 y10, 用户说明

Gui, Add, DropDownList, vInputStatus gInputCallback w90 h80 x10 y40 Choose1, 改造|精华|物品1|物品2|物品3|物品4|物品5|物品6

Gui, Add, Checkbox, vItemStatus x110 yp+2, 

Gui, Add, Text, w60 h25 x10 y70, X坐标:

Gui, Add, Edit, vInputXPos Number w60 h25 x70 yp-2, 0

Gui, Add, Text, w60 h25 x10 y100, Y坐标:

Gui, Add, Edit, vInputYPos Number w60 h25 x70 yp-2, 0

Gui, Add, Button, vSaveInfoStatus gSaveInfoCallback w120 h40 x10 y130, 保存信息

Gui, Add, Button, vShowInfoStatus gShowInfoCallback w120 h40 x10 y175, 显示信息

Gui, Add, Button, vGetMouseAddrStatus gGetMouseAddrCallback w120 h40 x10 y220, 坐标探测

Gui, Add, Text, x150 y40, 目标词缀：

Gui, Add, Edit, vModifiersStr1 w140 h25 x150 y70, %ModifiersStr1%

Gui, Add, Checkbox, vModifiersStatus1 x300 yp+2

Gui, Add, Edit, vModifiersStr2 w140 h25 x150 y100, %ModifiersStr2%

Gui, Add, Checkbox, vModifiersStatus2 x300 yp+2

Gui, Add, Edit, vModifiersStr3 w140 h25 x150 y130, %ModifiersStr3%

Gui, Add, Checkbox, vModifiersStatus3 x300 yp+2

Gui, Add, Edit, vModifiersStr4 w140 h25 x150 y160, %ModifiersStr4%

Gui, Add, Checkbox, vModifiersStatus4 x300 yp+2

Gui, Add, Edit, vModifiersStr5 w140 h25 x150 y190, %ModifiersStr5%

Gui, Add, Checkbox, vModifiersStatus5 x300 yp+2

Gui, Add, Edit, vModifiersStr6 w140 h25 x150 y220, %ModifiersStr6%

Gui, Add, Checkbox, vModifiersStatus6 x300 yp+2

Gui, Add, Edit, vModifiersStr7 w140 h25 x150 y250, %ModifiersStr7%

Gui, Add, Checkbox, vModifiersStatus7 x300 yp+2

Gui, Add, Edit, vModifiersStr8 w140 h25 x150 y280, %ModifiersStr8%

Gui, Add, Checkbox, vModifiersStatus8 x300 yp+2

Gui, Add, Edit, vModifiersStr9 w140 h25 x150 y310, %ModifiersStr9%

Gui, Add, Checkbox, vModifiersStatus9 x300 yp+2

Gui, Add, Edit, vModifiersStr10 w140 h25 x150 y340, %ModifiersStr10%

Gui, Add, Checkbox, vModifiersStatus10 x300 yp+2

Gui, Add, Text, +cBlue x150 y370, Designed By TTLzi.

IfNotExist, %ConfigFile%
{
	FileCreateDir, %A_ScriptDir%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	FileAppend, [AddrSettings]`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	FileAppend, AlterationXPos=0`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
		
	FileAppend, AlterationYPos=0`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
		
	FileAppend, EssenceXPos=0`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
		
	FileAppend, EssenceYPos=0`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Loop, 6 {
		FileAppend, ItemXPos%A_Index%=0`n, %ConfigFile%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
		
		FileAppend, ItemYPos%A_Index%=0`n, %ConfigFile%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	FileAppend, [BaseSettings]`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	FileAppend, InputStatus=改造`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Loop, 6 {
		FileAppend, ItemStatus%A_Index%=0`n, %ConfigFile%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	FileAppend, [ModifiersSettings]`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Loop, 10 {
		FileAppend, ModifiersStatus%A_Index%=0`n, %ConfigFile%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	Loop, 10 {
		FileAppend, ModifiersStr%A_Index%=`n, %ConfigFile%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	FileAppend, [Author's Word]`n自动改造&精华还算是简单。`n, %ConfigFile%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Sleep, 500
}

	IniRead, AlterationXPos, %ConfigFile%, AddrSettings, AlterationXPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniRead, AlterationYPos, %ConfigFile%, AddrSettings, AlterationYPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	IniRead, EssenceXPos, %ConfigFile%, AddrSettings, EssenceXPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniRead, EssenceYPos, %ConfigFile%, AddrSettings, EssenceYPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Loop, 6 {
		IniRead, ItemXPos%A_Index%, %ConfigFile%, AddrSettings, ItemXPos%A_Index%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
		
		IniRead, ItemYPos%A_Index%, %ConfigFile%, AddrSettings, ItemYPos%A_Index%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	IniRead, InputStatus, %ConfigFile%, BaseSettings, InputStatus
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	Loop, 6 {
		IniRead, ItemStatus%A_Index%, %ConfigFile%, BaseSettings, ItemStatus%A_Index%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	Loop, 10 {
		IniRead, ModifiersStatus%A_Index%, %ConfigFile%, ModifiersSettings, ModifiersStatus%A_Index%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	Loop, 10 {
		IniRead, ModifiersStr%A_Index%, %ConfigFile%, ModifiersSettings, ModifiersStr%A_Index%
		if ErrorLevel
		{
			GoSub, ErrorExitApp
		}
	}
	
	GuiControl, ChooseString, InputStatus, %InputStatus%
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	switch InputStatus
	{
		case "改造":
		{
			GuiControl, , InputXPos, %AlterationXPos%
			GuiControl, , InputYPos, %AlterationYPos%
			
			GuiControl, , ItemStatus, 0
			GuiControl, Disable, ItemStatus
		}
		
		case "精华":
		{
			GuiControl, , InputXPos, %EssenceXPos%
			GuiControl, , InputYPos, %EssenceYPos%
			
			GuiControl, , ItemStatus, 0
			GuiControl, Disable, ItemStatus
		}
		
		case "物品1":
		{
			GuiControl, , InputXPos, %ItemXPos1%
			GuiControl, , InputYPos, %ItemYPos1%
			
			GuiControl, , ItemStatus, %ItemStatus1%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品2":
		{
			GuiControl, , InputXPos, %ItemXPos2%
			GuiControl, , InputYPos, %ItemYPos2%
			
			GuiControl, , ItemStatus, %ItemStatus2%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品3":
		{
			GuiControl, , InputXPos, %ItemXPos3%
			GuiControl, , InputYPos, %ItemYPos3%
			
			GuiControl, , ItemStatus, %ItemStatus3%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品4":
		{
			GuiControl, , InputXPos, %ItemXPos4%
			GuiControl, , InputYPos, %ItemYPos4%
			
			GuiControl, , ItemStatus, %ItemStatus4%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品5":
		{
			GuiControl, , InputXPos, %ItemXPos5%
			GuiControl, , InputYPos, %ItemYPos5%
			
			GuiControl, , ItemStatus, %ItemStatus5%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品6":
		{
			GuiControl, , InputXPos, %ItemXPos6%
			GuiControl, , InputYPos, %ItemYPos6%
			
			GuiControl, , ItemStatus, %ItemStatus6%
			GuiControl, Enable, ItemStatus
		}
	}
	
	Loop, 10 {
		vModifiersStatus 	:= ModifiersStatus%A_Index%
		
		vModifiersStr		:= ModifiersStr%A_Index%
		
		GuiControl, , ModifiersStatus%A_Index%, %vModifiersStatus%
		
		GuiControl, , ModifiersStr%A_Index%, %vModifiersStr%
	}

Gui, Show, w350 h400, 自动改造&精华

Hotkey, ^!o, ProgramSwitch, On

return
;/***********************************函 数*************************************l*/
ProgramSwitch:

    Gui, Submit, NoHide

    ProgramStatus := ~ProgramStatus

    if ProgramStatus
    {
		ToolTip, 程序即将打开！
		Sleep, 1000
		ToolTip
		
        ;设置文本颜色为绿色
		GuiControl, +cGreen, ProgramStatusText
		
		;更新文本
		GuiControl,, ProgramStatusText, 运行
		
		GuiControl, Disable, InputStatus
		;GuiControl, Disable, ItemStatus
		GuiControl, Disable, InputXPos
		GuiControl, Disable, InputYPos
		GuiControl, Disable, SaveConfigStatus
		GuiControl, Disable, SaveInfoStatus
		GuiControl, Disable, ShowInfoStatus
		GuiControl, Disable, GetMouseAddrStatus
		
		Loop, 10 {
			GuiControl, Disable, ModifiersStr%A_Index%
			
			GuiControl, Disable, ModifiersStatus%A_Index%
		}

		;/*< 1.检查位置是否超出屏幕范围 >*/
		if(AlterationXPos < 0 || AlterationXPos > A_ScreenWidth || AlterationYPos < 0 || AlterationYPos > A_ScreenHeight)
		{
			MsgBox, 改造石位置错误！不应该超过主屏幕范围！

			GoSub, ProgramSwitch

			return
		}

		if(EssenceXPos < 0 || EssenceXPos > A_ScreenWidth || EssenceYPos < 0 || EssenceYPos > A_ScreenHeight)
		{
			MsgBox, 精华位置错误！不应该超过主屏幕范围！

			GoSub, ProgramSwitch

			return
		}

		Loop, 6 {

			if(ItemXPos%A_Index% < 0 || ItemXPos%A_Index% > A_ScreenWidth || ItemYPos%A_Index% < 0 || ItemYPos%A_Index% > A_ScreenHeight)
			{
				MsgBox,第%A_Index%个物品位置错误！不应该超过主屏幕范围！

				GoSub, ProgramSwitch

				return
			}
		}

		;/*< 2.检查改造石/精华位置并且获取它们的堆叠数量 >*/
		switch InputStatus
		{
			case "改造":
			{
				AlterationMaxNum := CheckCurrencyStatus(AlterationXPos,AlterationYPos,"改造石")
			}

			case "精华":
			{
				EssenceMaxNum := CheckCurrencyStatus(AlterationXPos,AlterationYPos,"精华")
			}

			Default:
			{
				MsgBox, 只有在改造和精华选项下能够运行程序，请修改！即将退出程序！

				GoSub, ProgramSwitch

				return
			}
		}

		;/*< 3.获取第一个要使用的物品坐标，从6个里面找到一个就好了 >*/
		Loop, 6 {

			vItemStatus := ItemStatus%A_Index%

			if vItemStatus
			{
				ItemXPos_Temp := ItemXPos%A_Index%
				ItemYPos_Temp := ItemYPos%A_Index%
				ItemIndex_Temp := A_Index
				ItemIndex_Old := A_Index
				break
			}
		}
		
		if (ItemIndex_Old = 0)
		{
			MsgBox, 所有物品都未勾选，请勾选后再开启程序！程序即将退出！
			
			GoSub, ProgramSwitch
			
			return
		}
		
		;/*< 打开自动操作程序 >*/
		SetTimer, ProgramHandle, 1000
    }
    else
    {
        ToolTip, 程序即将关闭！
		Sleep, 1000
		ToolTip

		;设置文本颜色为红色
		GuiControl, +cRed, ProgramStatusText
		
		;更新文本
		GuiControl,, ProgramStatusText, 停止
		
		GuiControl, Enable, InputStatus
		GuiControl, Enable, InputXPos
		GuiControl, Enable, InputYPos
		GuiControl, Enable, SaveConfigStatus
		GuiControl, Enable, SaveInfoStatus
		GuiControl, Enable, ShowInfoStatus
		GuiControl, Enable, GetMouseAddrStatus
		
		Loop, 10 {
			GuiControl, Enable, ModifiersStr%A_Index%
			
			GuiControl, Enable, ModifiersStatus%A_Index%
		}
		
		;/*< 关闭自动操作程序 >*/
		SetTimer, ProgramHandle, Off
		
		;/*< 解锁，确保下次打开必定能够上锁 >*/
		ProgramHandleMutex := 0
    }
	
return

CheckCurrencyStatus(XPos,YPos,CurrencyType)
{
	;/*< 1.参数校验 >*/
	if(XPos < 0 || XPos >= A_ScreenWidth || YPos < 0 || YPos >= A_ScreenHeight || !StrLen(CurrencyType))
	{
		return 5001
	}
	
	;/*< 2.清空剪切板 >*/
	Clipboard := ""
	
	;/*< 3.鼠标移动至传入坐标处 >*/
	MouseMove, %XPos%, %YPos%
	
	;/*< 4.向键盘发送Ctrl + C >*/
	Send, ^C
	
	;/*< 4.等待剪切板读取成功 >*/
	ClipWait, 0.2, 1
	
	;/*< 剪切板为空 >*/
	if(!Clipboard)
	{
		vCount := 0
		
		;/*< 尝试循环读取10次 >*/
		while(++vCount <= 10)
		{
			MouseMove, %XPos%, %YPos%		
			
			Sleep, 100
			
			;/*< 仅仅等待，不强制检查变化 >*/
			ClipWait, 0.2
			
			;/*< 假如剪切板非空则退出while循环 >*/
			if(Clipboard)
			{
				break
			}
		}
	}
	
	;5.剪切板非空且检测且字符串匹配成功
	if(Clipboard && InStr(Clipboard,%CurrencyType%))
	{
		;/*< 匹配堆叠数量 >*/
		if InStr(Clipboard,"堆叠数量")
		{
			;/*< 正则匹配数字 >*/
			RegExMatch(Clipboard, "(\d+)(?:,(\d+))*?/", matches)

			;/*< 获取逗号前的字符串型数据 >*/
			MaxNumString := matches1  

			;/*< 如果有逗号，获取逗号后的字符串型数据 >*/
			if matches2
				MaxNumString .= matches2

			;/*< 将字符串型数据转化为数字 >*/
			MaxNum := MaxNumString + 0

			;/*< 将获取到的数字返回出去 >*/
			return MaxNum
		}

		return 0
	}
	
	;/*< 6.否则返回5001 >*/
	return 5001
}

ProgramHandle:

	vMapOperationStatus := 0
	
	;/*< 假如已上锁，退出，避免多线程并行 >*/
	if ProgramHandleMutex
		return
	
	;/*< 上锁 >*/
	ProgramHandleMutex := 1

	;/*< 清空剪切板内容 >*/
	Clipboard := ""

	;/*< 鼠标移动至物品坐标处 >*/
	MouseMove, ItemXPos_Temp, ItemYPos_Temp
	
	;/*< 等待一会，主要是考虑到服务器的反应是要时间的 >*/
	Sleep, 100
	
	;/*< 发送Ctrl + C命令给键盘 >*/
	Send, ^C
	
	;/*< 等待0.2s观察剪切板内是否有数据读出 >*/
	ClipWait, 0.2, 1
	
	;/*< 没有数据读出，尝试10次 >*/
	if(!Clipboard)
	{
		vCount := 0
		
		while(++vCount <= 10)
		{
			MouseMove, ItemXPos_Temp, ItemYPos_Temp					
			
			Sleep, 100
			
			;/*< 仅仅判断剪切板有无更新 >*/
			ClipWait, 0.2
			
			;/*< 成功读取到一次即退出 >*/
			if(Clipboard)
			{
				break
			}
		}
	}
	
	;/*< 剪切版内有内容 >*/
	if(Clipboard)
	{
		;/*< 匹配10次 >*/
		Loop, 10 {

			vModifiersStatus := ModifiersStatus%A_Index%

			vModifiersStr := ModifiersStr%A_Index%
			
			;/*< 假如词缀勾选了 >*/
			if vModifiersStatus
			{
				;/*< 假如词缀匹配了 >*/
				if InStr(Clipboard,vModifiersStr)
				{
					;/*< 物品不需要操作 >*/
					vMapOperationStatus := 1
					
					;/*< 退出Loop循环 >*/
					break
				}
			}
		}
	}
	else
	{
		MsgBox, 未检测到物品！即将退出程序！
		
		GoSub, ProgramSwitch
		
		Goto, ExitProgramHandle
	}

	;/*< 物品需要操作 >*/
	if(vMapOperationStatus = 0)
	{
		if(InputStatus = "改造")
		{
			;/*< 鼠标移动到改造石 >*/
			MouseMove, AlterationXPos, AlterationYPos
			
			;/*< 右键单击 >*/
			Click, Right, AlterationXPos, AlterationYPos

			;/*< 鼠标移动到物品坐标 >*/
			MouseMove, ItemXPos_Temp, ItemYPos_Temp

			;/*< 左键单击 >*/
			Click, ItemXPos_Temp, ItemYPos_Temp
			
			;/*< 改造石最大堆叠数量-1 >*/
			AlterationMaxNum -= 1
			
			if(AlterationMaxNum = 0)
			{
				MsgBox, 改造石最大堆叠数量为0，请补充！
				
				GoSub, ProgramSwitch
				
				return
			}

			Sleep, 100
		}
		else if(InputStatus = "精华")
		{
			;/*< 鼠标移动到精华 >*/
			MouseMove, EssenceXPos, EssenceYPos

			;/*< 右键单击 >*/
			Click, Right, EssenceXPos, EssenceYPos

			;/*< 鼠标移动到物品坐标 >*/
			MouseMove, ItemXPos_Temp, ItemYPos_Temp

			;/*< 左键单击 >*/
			Click, ItemXPos_Temp, ItemYPos_Temp
			
			;/*< 精华最大堆叠数量-1 >*/
			EssenceMaxNum -= 1
			
			if(EssenceMaxNum = 0)
			{
				MsgBox, 精华最大堆叠数量为0，请补充！
				
				GoSub, ProgramSwitch
				
				return
			}

			Sleep, 100
		}
		
		;/*< 退出程序 >*/
		Goto, ExitProgramHandle
	}
	
	;/*< 物品无需操作，找到下一个物品坐标 >*/
	Loop, 6{

		vItemStatus := ItemStatus%A_Index%

		if(ItemIndex_Temp < A_Index && vItemStatus != 0)
		{
			ItemXPos_Temp := ItemXPos%A_Index%

			ItemYPos_Temp := ItemYPos%A_Index%
			
			ItemIndex_Temp := A_Index

			break
		}
	}
	
	;/*< 假如未找到下一个物品坐标，应该给用户提示，并且退出程序 >*/
	if(ItemIndex_Temp = ItemIndex_Old)
	{
		MsgBox, 搞定%ItemIndex_Old%件物品！

		GoSub, ProgramSwitch

		Goto, ExitProgramHandle
	}
	;/*< 假如找到了下一个物品坐标，将坐标Index记录下来 >*/
	else
		ItemIndex_Old := ItemIndex_Temp

	ExitProgramHandle:
	
	;/*< 解锁 >*/
	ProgramHandleMutex := 0

return

SaveConfigCallback:
	
	;/*< 写入改造石坐标 >*/
	IniWrite, %AlterationXPos%, %ConfigFile%, AddrSettings, AlterationXPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %AlterationYPos%, %ConfigFile%, AddrSettings, AlterationYPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 写入精华坐标 >*/
	IniWrite, %EssenceXPos%, %ConfigFile%, AddrSettings, EssenceXPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %EssenceYPos%, %ConfigFile%, AddrSettings, EssenceYPos
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 写入物品坐标 >*/
	IniWrite, %ItemXPos1%, %ConfigFile%, AddrSettings, ItemXPos1
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos1%, %ConfigFile%, AddrSettings, ItemYPos1
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemXPos2%, %ConfigFile%, AddrSettings, ItemXPos2
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos2%, %ConfigFile%, AddrSettings, ItemYPos2
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemXPos3%, %ConfigFile%, AddrSettings, ItemXPos3
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos3%, %ConfigFile%, AddrSettings, ItemYPos3
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemXPos4%, %ConfigFile%, AddrSettings, ItemXPos4
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos4%, %ConfigFile%, AddrSettings, ItemYPos4
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemXPos5%, %ConfigFile%, AddrSettings, ItemXPos5
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos5%, %ConfigFile%, AddrSettings, ItemYPos5
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemXPos6%, %ConfigFile%, AddrSettings, ItemXPos6
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemYPos6%, %ConfigFile%, AddrSettings, ItemYPos6
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 写入输入选项坐标 >*/
	IniWrite, %InputStatus%, %ConfigFile%, BaseSettings, InputStatus
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 物品状态 >*/
	IniWrite, %ItemStatus1%, %ConfigFile%, BaseSettings, ItemStatus1
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemStatus2%, %ConfigFile%, BaseSettings, ItemStatus2
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemStatus3%, %ConfigFile%, BaseSettings, ItemStatus3
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemStatus4%, %ConfigFile%, BaseSettings, ItemStatus4
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemStatus5%, %ConfigFile%, BaseSettings, ItemStatus5
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ItemStatus6%, %ConfigFile%, BaseSettings, ItemStatus6
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 目标词缀状态 >*/
	IniWrite, %ModifiersStatus1%, %ConfigFile%, ModifiersSettings, ModifiersStatus1
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus2%, %ConfigFile%, ModifiersSettings, ModifiersStatus2
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus3%, %ConfigFile%, ModifiersSettings, ModifiersStatus3
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus4%, %ConfigFile%, ModifiersSettings, ModifiersStatus4
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus5%, %ConfigFile%, ModifiersSettings, ModifiersStatus5
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus6%, %ConfigFile%, ModifiersSettings, ModifiersStatus6
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus7%, %ConfigFile%, ModifiersSettings, ModifiersStatus7
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus8%, %ConfigFile%, ModifiersSettings, ModifiersStatus8
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStatus9%, %ConfigFile%, ModifiersSettings, ModifiersStatus9
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
    IniWrite, %ModifiersStatus10%, %ConfigFile%, ModifiersSettings, ModifiersStatus10
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
	;/*< 目标词缀内容 >*/
	IniWrite, %ModifiersStr1%, %ConfigFile%, ModifiersSettings, ModifiersStr1
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr2%, %ConfigFile%, ModifiersSettings, ModifiersStr2
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr3%, %ConfigFile%, ModifiersSettings, ModifiersStr3
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr4%, %ConfigFile%, ModifiersSettings, ModifiersStr4
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr5%, %ConfigFile%, ModifiersSettings, ModifiersStr5
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr6%, %ConfigFile%, ModifiersSettings, ModifiersStr6
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr7%, %ConfigFile%, ModifiersSettings, ModifiersStr7
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr8%, %ConfigFile%, ModifiersSettings, ModifiersStr8
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	IniWrite, %ModifiersStr9%, %ConfigFile%, ModifiersSettings, ModifiersStr9
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
    IniWrite, %ModifiersStr10%, %ConfigFile%, ModifiersSettings, ModifiersStr10
	if ErrorLevel
	{
		GoSub, ErrorExitApp
	}
	
return

InputCallback:
	
	Gui, Submit, NoHide
	
	;/*< 当输入选项更改时，应当显示出它默认的坐标 >*/
	switch InputStatus
	{
		case "改造":
		{
			GuiControl, , InputXPos, %AlterationXPos%
			GuiControl, , InputYPos, %AlterationYPos%
			
			GuiControl, , ItemStatus, 0
			GuiControl, Disable, ItemStatus
		}
		
		case "精华":
		{
			GuiControl, , InputXPos, %EssenceXPos%
			GuiControl, , InputYPos, %EssenceYPos%
			
			GuiControl, , ItemStatus, 0
			GuiControl, Disable, ItemStatus
		}
		
		case "物品1":
		{
			GuiControl, , InputXPos, %ItemXPos1%
			GuiControl, , InputYPos, %ItemYPos1%
			
			GuiControl, , ItemStatus, %ItemStatus1%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品2":
		{
			GuiControl, , InputXPos, %ItemXPos2%
			GuiControl, , InputYPos, %ItemYPos2%
			
			GuiControl, , ItemStatus, %ItemStatus2%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品3":
		{
			GuiControl, , InputXPos, %ItemXPos3%
			GuiControl, , InputYPos, %ItemYPos3%
			
			GuiControl, , ItemStatus, %ItemStatus3%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品4":
		{
			GuiControl, , InputXPos, %ItemXPos4%
			GuiControl, , InputYPos, %ItemYPos4%
			
			GuiControl, , ItemStatus, %ItemStatus4%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品5":
		{
			GuiControl, , InputXPos, %ItemXPos5%
			GuiControl, , InputYPos, %ItemYPos5%
			
			GuiControl, , ItemStatus, %ItemStatus5%
			GuiControl, Enable, ItemStatus
		}
		
		case "物品6":
		{
			GuiControl, , InputXPos, %ItemXPos6%
			GuiControl, , InputYPos, %ItemYPos6%
			
			GuiControl, , ItemStatus, %ItemStatus6%
			GuiControl, Enable, ItemStatus
		}
	}
return

SaveInfoCallback:

	Gui, Submit, NoHide

	switch InputStatus
	{
		case "改造":
		{
			AlterationXPos := InputXPos
			AlterationYPos := InputYPos
		}
		
		case "精华":
		{
			EssenceXPos := InputXPos
			EssenceYPos := InputYPos
		}
		
		case "物品1":
		{
			ItemXPos1 := InputXPos
			ItemYPos1 := InputYPos
			ItemStatus1 := ItemStatus
		}
		
		case "物品2":
		{
			ItemXPos2 := InputXPos
			ItemYPos2 := InputYPos
			ItemStatus2 := ItemStatus
		}
		
		case "物品3":
		{
			ItemXPos3 := InputXPos
			ItemYPos3 := InputYPos
			ItemStatus3 := ItemStatus
		}
		
		case "物品4":
		{
			ItemXPos4 := InputXPos
			ItemYPos4 := InputYPos
			ItemStatus4 := ItemStatus
		}
		
		case "物品5":
		{
			ItemXPos5 := InputXPos
			ItemYPos5 := InputYPos
			ItemStatus5 := ItemStatus
		}
		
		case "物品6":
		{
			ItemXPos6 := InputXPos
			ItemYPos6 := InputYPos
			ItemStatus6 := ItemStatus
		}
	}
	
return

ShowInfoCallback:
	
	vShowStr .= "改造坐标: (" AlterationXPos ", " AlterationYPos ")`n"
	vShowStr .= "精华坐标: (" EssenceXPos ", " EssenceYPos ")`n"
	vShowStr .= "物品1坐标: (" ItemXPos1 ", " ItemYPos1 ")`n"
	vShowStr .= "物品2坐标: (" ItemXPos2 ", " ItemYPos2 ")`n"
	vShowStr .= "物品3坐标: (" ItemXPos3 ", " ItemYPos3 ")`n"
	vShowStr .= "物品4坐标: (" ItemXPos4 ", " ItemYPos4 ")`n"
	vShowStr .= "物品5坐标: (" ItemXPos5 ", " ItemYPos5 ")`n"
	vShowStr .= "物品6坐标: (" ItemXPos6 ", " ItemYPos6 ")`n"
	
	vShowStr .= "目标词缀1: " ModifiersStr1 "`n"
	vShowStr .= "目标词缀2: " ModifiersStr2 "`n"
	vShowStr .= "目标词缀3: " ModifiersStr3 "`n"
	vShowStr .= "目标词缀4: " ModifiersStr4 "`n"
	vShowStr .= "目标词缀5: " ModifiersStr5 "`n"
	vShowStr .= "目标词缀6: " ModifiersStr6 "`n"
	vShowStr .= "目标词缀7: " ModifiersStr7 "`n"
	vShowStr .= "目标词缀8: " ModifiersStr8 "`n"
	vShowStr .= "目标词缀9: " ModifiersStr9 "`n"
	vShowStr .= "目标词缀10: " ModifiersStr10 "`n"

	; 输出到 MsgBox
	MsgBox, 0x40, 显示信息, %vShowStr%
	
	vShowStr := ""
	
return

GetMouseAddrCallback:

	GetMouseAddrStatus := ~GetMouseAddrStatus
	
	if GetMouseAddrStatus
	{
		;/*< 以1000ms为时基打开探测坐标定时器 >*/
		SetTimer, GetMouseAddrAction, 1000
		
		;/*< 修改文本显示 >*/
		GuiControl, Text, GetMouseAddrStatus, 停止探测
	}
	else
	{
		;/*< 关闭探测坐标定时器 >*/
		SetTimer, GetMouseAddrAction, Off
		
		;/*< 修改文本显示 >*/
		GuiControl, Text, GetMouseAddrStatus, 坐标探测
	}
	
return

GetMouseAddrAction:

	;/*< 设置扫描模式为屏幕 >*/
	CoordMode, Mouse, Screen
	
	;/*< 获取当前屏幕的XY坐标 >*/
	MouseGetPos, MouseXPos, MouseYPos
	
	;/*< 将XY坐标组成一个字符串 >*/
	vMouseAddrStr := Format("{1}{2}{3}{4}{5}","当前坐标:(",MouseXPos,".",MouseYPos,")")
	
	;/*< 显示出来告诉用户当前鼠标坐标 >*/
	ToolTip, %vMouseAddrStr%
	Sleep, 999
	ToolTip
	
return

UserManualCallback:
	
	;弹出消息框通知用户
	vShowStr .= "第一次按下Ctrl + Alt + O程序运行，再次按下Ctrl + Alt + O程序停止。`n"
	vShowStr .= "要先点击保存信息再点击保存配置。`n"
	vShowStr .= "有问题找我发邮箱给我，邮箱:doctortzb@163.com`n"
	
	MsgBox, 0x40, 用户说明, %vShowStr%
	
	vShowStr = ""
return

ErrorExitApp:
	
	vShowStr .= "配置文件读取/写入失败！`n"
	vShowStr .= "请检查配置文件的权限！`n"
	vShowStr .= "即将退出软件！`n"
	
	MsgBox, 0x40, 配置文件错误, %vShowStr%
	
	vShowStr = ""
	
ExitApp

GuiClose:
	;/*< 退出前应该保存一次当前配置 >*/
	GoSub, SaveConfigCallback
ExitApp
